package com.abei.gas.controller;

import cn.hutool.core.util.StrUtil;
import com.abei.gas.entity.Card;
import com.abei.gas.entity.Device;
import com.abei.gas.entity.Payorder;
import com.abei.gas.service.PayorderService;
import com.abei.gas.vo.DataVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/payorder")
@Api(tags = "支付管理相关接口")
public class PayorderController {
    
    @Autowired
    private PayorderService payorderService;
    
    @PostMapping("/insert")
    public DataVo insert(@RequestBody Payorder payorder){
        payorderService.save(payorder);
        return DataVo.success();
    }

    @PostMapping("/deleteById")
    public DataVo deleteById(@RequestBody List<String> ids){
        payorderService.removeByIds(ids);
        return DataVo.success();
    }

    @PostMapping("/update")
    public DataVo update (@RequestBody Payorder payorder){
        payorderService.updateById(payorder);
        return DataVo.success();
    }

    @GetMapping("/findAll")
    public DataVo<Payorder> findAll(Integer page, Integer limit){
        return payorderService.findAll(page,limit);
    }

    //搜索
    @GetMapping("/selectById")
    public DataVo<Payorder> selectById(HttpServletRequest request) {
        String id = request.getParameter("id");
        return payorderService.findById(id);
    }

    @PostMapping("/pay")
    public DataVo pay(@RequestBody Payorder payorder){
        payorderService.pay(payorder);
        return DataVo.success();
    }
}
